<?xml version="1.0" encoding="UTF-8"?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:p="http://primefaces.org/ui"
                template="/templates/general.xhtml">

    <ui:define name="title"><h:outputText value="Code Editor" /></ui:define>
    <ui:define name="header"><h:outputText value="Code Editor" /></ui:define>

    <ui:define name="content">

        <h:form id="form" style="min-height: 500px;">
            <p:breadCrumb>
                <p:menuitem value="Home" update="@form" url=""/>
                <p:menuitem value="Add Source" update="@form" url="/pages/editor.xhtml" />
                <p:menuitem value="History" update="@form" url="/pages/journal.xhtml" />
                <p:menuitem value="Logout" update="@form" action="#{userSession.logout()}" />
            </p:breadCrumb>
            <p:fieldset styleClass="fieldset" legend="Code Editor" style="min-height: 350px; width: 95%;">
                <div>
                    <p:messages id="messages" />
                    <h:panelGrid id="regPanelGrid" style="margin: auto;" cellspacing="0" columns="1">
                        <h:panelGroup>
                            <div id="fileUploadArea"  >
                                <h3>You can upload a file</h3>
                                <p:fileUpload fileUploadListener="#{createActivityService.loadFile}"
                                              update="@form"
                                              dragDropSupport="true"
                                              mode="advanced"
                                              auto="true" allowTypes="/(\.|\/)(java|txt)$/" />
                            </div> 
                        </h:panelGroup>
                        <h:panelGroup>
                            <div id="codeEditor" >
                                <h3>Or just paste your code here</h3>
                                <p:inputTextarea id="sourceCode" value="#{createActivityService.sourceCode}" 
                                                 style="font-size: 13px; resize: none;" autoResize="false" 
                                                 rows="20" cols="100" />
                                <br /><br />
                                <p:commandButton id="createActivityButton"
                                                 action="#{viewerBean.redirect(createActivityService.createActivity())}"
                                                 value="Add to library"
                                                 ajax="false"/>
                            </div> 
                        </h:panelGroup>
                    </h:panelGrid>
                </div>
            </p:fieldset>
        </h:form>
    </ui:define>
</ui:composition>